//二分查找
#include<stdio.h>
#pragma warning(disable:4996)
int My_Find(int arr[], int find,int size)
{
	int left, right, mid;
	 left = 0;
	 right = size;
	 while (left<right)
	 {
		 mid = left + ((right - left) >> 1);
		 //防止溢出
		 if (find < arr[mid])
			 right = mid;//左闭右开
		 else if (find > arr[mid])
			 left = mid + 1;
		 else
			 return mid;
	 }
	 return 0;
}
int main()
{
	int arr[10] = { 1,2,3,4,5,6,7,8,9,10};
	int find,size;
	size = sizeof(arr) / sizeof(arr[0]);
	scanf("%d", &find);
	int ret = My_Find(arr, find, size);
	if (ret)
		printf("arr[%d]:%d\n", ret, find);
	else
		printf("未查找到!\n");
	return 0;

}